﻿#Region "MediaFileComparisons"
Public Class MediaFileFileSizeComparer
    Implements IComparer(Of IMediaFile)

    Public Overloads Function Compare(ByVal x As IMediaFile, ByVal y As IMediaFile) As Integer Implements System.Collections.Generic.IComparer(Of IMediaFile).Compare
        If x.FileSize < y.FileSize Then
            Return -1
        ElseIf x.FileSize = y.FileSize Then
            Return 0
        Else
            Return 1
        End If
    End Function
End Class

Public Class MediaFileFileTypeComparer
    Implements IComparer(Of IMediaFile)

    Public Overloads Function Compare(ByVal x As IMediaFile, ByVal y As IMediaFile) As Integer Implements System.Collections.Generic.IComparer(Of IMediaFile).Compare
        If CInt(x.FileType) < CInt(y.FileType) Then
            Return -1
        ElseIf CInt(x.FileType) = CInt(y.FileType) Then
            Return 0
        Else
            Return 1
        End If
    End Function
End Class

#Region "Audio File Comparisions"
Public Class AudioFileTrackNumberComparer
    Implements IComparer(Of IAudioMediaFile)

    Public Function Compare(ByVal x As IAudioMediaFile, ByVal y As IAudioMediaFile) As Integer Implements System.Collections.Generic.IComparer(Of IAudioMediaFile).Compare
        If x.TrackNumber > y.TrackNumber Then
            Return -1
        ElseIf x.TrackNumber = y.TrackNumber Then
            Return 0
        ElseIf x.TrackNumber < y.TrackNumber Then
            Return 1
        End If
    End Function
End Class

Public Class AudioFileArtistComparer
    Implements IComparer(Of IAudioMediaFile)

    Public Function Compare(ByVal x As IAudioMediaFile, ByVal y As IAudioMediaFile) As Integer Implements System.Collections.Generic.IComparer(Of IAudioMediaFile).Compare
        If x.Creators(0).Name < y.Creators(0).Name Then
            Return -1
        ElseIf x.Creators(0).Name = y.Creators(0).Name Then
            Return 0
        Else
            Return 1
        End If
    End Function
End Class
#End Region

#Region "Image File Comparisons"
Public MustInherit Class ImageFileComparisonBase
    Implements IComparer(Of IImageMediaFile)

    Public MustOverride Function Compare(ByVal x As IImageMediaFile, ByVal y As IImageMediaFile) As Integer Implements System.Collections.Generic.IComparer(Of IImageMediaFile).Compare
End Class

Public Class ImageFileDimensionComparer
    Inherits ImageFileComparisonBase

    Public Overrides Function Compare(ByVal x As IImageMediaFile, ByVal y As IImageMediaFile) As Integer
        If x.Dimensions < y.Dimensions Then
            Return -1
        ElseIf x.Dimensions = y.Dimensions Then
            Return 0
        Else
            Return 1
        End If
    End Function
End Class
#End Region
#End Region